package org.ubik.filtertreetable.tree.sample;

import java.awt.Component;
import java.awt.Font;

import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;

/**
 * this class is a sample of tree renderer
 * @author remi
 *
 */
@SuppressWarnings("serial")
public class MySampleFilterTreeRenderer extends DefaultTreeCellRenderer {
 
	@Override
	public Component getTreeCellRendererComponent(
            JTree tree,
            Object value,
            boolean sel,
            boolean expanded,
            boolean leaf,
            int row,
            boolean hasFocus) {

		super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
		
		DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
		String	labelText = (String)node.getUserObject();
				
		int level = node.getLevel();
		
		if(level == 0){
			this.setFont(new Font("arial", Font.PLAIN, 12));
		}
		else{
			this.setFont(new Font("arial", Font.PLAIN, 15));
		}
		
		this.setText(labelText);
		
		tree.setRowHeight(16);
		return this;
	}
	
}
